﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:v="clr-namespace:ShredTheLog.Views;assembly=ShredTheLog.Views"
    xmlns:vm="clr-namespace:ShredTheLog.ViewModels;assembly=ShredTheLog.ViewModels"
    xmlns:cnv="clr-namespace:ShredTheLog.Converters;assembly=ShredTheLog.Converters"
    xmlns:generated="clr-namespace:ShredTheLog.Api;assembly=ShredTheLog.Generated"
    xmlns:c="clr-namespace:ShredTheLog.Controls;assembly=ShredTheLog.Controls"
    xmlns:tk="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
    xmlns:dgp="clr-namespace:Microsoft.Windows.Controls.Primitives;assembly=WPFToolkit"
    xmlns:s="clr-namespace:System;assembly=mscorlib"
    >

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="CommonImages\GenderImages.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <DataTemplate DataType="{x:Type generated:Language}">
        <TextBlock Text="{Binding Converter={x:Static cnv:LanguagesConverter.Default}}"/>
    </DataTemplate>

    <DataTemplate DataType="{x:Type generated:Country}">
        <TextBlock Text="{Binding Converter={x:Static cnv:CountryConverter.Default}}"/>
    </DataTemplate>

    <DataTemplate DataType="{x:Type generated:Gender}">
        <DataTemplate.Resources>
            <DrawingImage x:Key="MaleImage">
                <DrawingImage.Drawing>
                    <GeometryDrawing Brush="Black" Geometry="{StaticResource MaleGeometry}"/>
                </DrawingImage.Drawing>
            </DrawingImage>

            <DrawingImage x:Key="FemaleImage">
                <DrawingImage.Drawing>
                    <GeometryDrawing Brush="Black" Geometry="{StaticResource FemaleGeometry}"/>
                </DrawingImage.Drawing>
            </DrawingImage>
        </DataTemplate.Resources>

        <Image x:Name="image" Width="12" Height="12"/>

        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding}" Value="Male">
                <Setter TargetName="image" Property="Source" Value="{StaticResource MaleImage}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding}" Value="Female">
                <Setter TargetName="image" Property="Source" Value="{StaticResource FemaleImage}"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate DataType="{x:Type vm:OnlineStatus}">
        <DataTemplate.Resources>

            <RadialGradientBrush x:Key="IndeterminateBrush" GradientOrigin="0.4, 0.4">
                <GradientStop Offset="0" Color="#C0C0C0"/>
                <GradientStop Offset="1" Color="#404040"/>
            </RadialGradientBrush>

            <RadialGradientBrush x:Key="OnlineBrush" GradientOrigin="0.4, 0.4">
                <GradientStop Offset="0" Color="#00FF00"/>
                <GradientStop Offset="1" Color="#404040"/>
            </RadialGradientBrush>

            <RadialGradientBrush x:Key="OfflineBrush" GradientOrigin="0.4, 0.4">
                <GradientStop Offset="0" Color="#FF0000"/>
                <GradientStop Offset="1" Color="#404040"/>
            </RadialGradientBrush>
            
        </DataTemplate.Resources>

        <Ellipse x:Name="pad" Fill="{StaticResource IndeterminateBrush}" Width="16" Height="16"/>
        
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding}" Value="Online">
                <Setter TargetName="pad" Property="Fill" Value="{StaticResource OnlineBrush}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding}" Value="Offline">
                <Setter TargetName="pad" Property="Fill" Value="{StaticResource OfflineBrush}"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
    
    <Style TargetType="{x:Type FlowDocument}">
        <Setter Property="FontFamily" Value="Segoe UI"/>
        <Setter Property="FontSize" Value="12"/>
    </Style>

    <Style TargetType="{x:Type tk:DataGrid}">
        <Setter Property="IsReadOnly" Value="True"/>
        <Setter Property="IsSynchronizedWithCurrentItem" Value="True"/>
        <Setter Property="AutoGenerateColumns" Value="False"/>
        <Setter Property="SelectionMode" Value="Single"/>
        <Setter Property="RowHeaderStyle" Value="{x:Null}"/>
        <Setter Property="RowHeaderWidth" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type tk:DataGrid}">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
                        <ScrollViewer Focusable="false" Name="DG_ScrollViewer">
                            <ScrollViewer.Template>
                                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>

                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>

                                        <!--Left Column Header Corner -->
                                        <!--<Button Command="{x:Static dg:DataGrid.SelectAllCommand}" Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type tk:DataGrid}}, Path=CellsPanelHorizontalOffset}" Template="{StaticResource SelectAllButtonTemplate}" Focusable="false" Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type tk:DataGrid}}, Path=HeadersVisibility, Converter={x:Static tk:DataGrid.HeadersVisibilityConverter}, ConverterParameter={x:Static tk:DataGridHeadersVisibility.All}}" />-->

                                        <!--Column Headers-->
                                        <dgp:DataGridColumnHeadersPresenter Grid.Column="1" Name="PART_ColumnHeadersPresenter" Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type tk:DataGrid}}, Path=HeadersVisibility, Converter={x:Static tk:DataGrid.HeadersVisibilityConverter}, ConverterParameter={x:Static tk:DataGridHeadersVisibility.Column}}"/>

                                        <!--DataGrid content-->
                                        <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" Grid.Row="1" Grid.ColumnSpan="2" CanContentScroll="{TemplateBinding CanContentScroll}" />

                                        <ScrollBar Grid.Row="1" Grid.Column="2" Name="PART_VerticalScrollBar" Orientation="Vertical" Maximum="{TemplateBinding ScrollableHeight}" ViewportSize="{TemplateBinding ViewportHeight}" Value="{Binding Path=VerticalOffset, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>

                                        <Grid Grid.Row="2" Grid.Column="1">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type tk:DataGrid}}, Path=NonFrozenColumnsViewportHorizontalOffset}"/>
                                                <ColumnDefinition Width="*"/>
                                            </Grid.ColumnDefinitions>
                                            <ScrollBar Grid.Column="1" Name="PART_HorizontalScrollBar" Orientation="Horizontal" Maximum="{TemplateBinding ScrollableWidth}" ViewportSize="{TemplateBinding ViewportWidth}" Value="{Binding Path=HorizontalOffset, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>
                                        </Grid>
                                    </Grid>
                                </ControlTemplate>
                            </ScrollViewer.Template>
                            <ItemsPresenter/>
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="c:Extensions.IsCustomSortingEnabled" Value="True"/>
    </Style>

</ResourceDictionary>